Automatic optimization techniques for software programs are becoming a more prevalent method for optimizing programs. Often, optimization of a program requires that the behavior of the program be monitored during execution. Monitoring the application during execution allows information to be gathered about the program's performance. Various techniques are used to gather this information. Once the information is gathered, the data may be used to optimize the program for future performance enhancement.
Some techniques for optimizing a program are simply referred to as Profile-Based Optimization (PBO) techniques. This set of techniques allow programs to be optimized more fully than when a program is not analyzed during execution. When a PBO technique is used for analyzing and optimizing a program, a consideration of the effectiveness of the technique is how much of the program was tested/analyzed. One type of profiling allows the parts of the program that are covered by the test to be discovered, so that the effectiveness of the PBO technique may be determined.
Typically, profiling is done in two alternate ways. The first is to use instrumentation. In an instrumentation approach, the program is modified so that it produces the profile information as it executes. The instrumentation approach therefore requires the program to be modified. Extra instructions are inserted within the program to compute and store the profile information. A burden therefore lies on the programmer to generate a new version of the program that needs to be installed and otherwise handled specially. Depending on the type of profile information desired, the instrumented program may run significantly slower (e.g., between 2 and 50 times slower) than the original.
The second profiling alternative is to statistically sample the program's behavior. Typically, in a sampling approach, a hardware timer is used to interrupt the program as it is running and the state at the interruption point is inspected to determine what instruction is being executed. Sampling can be done on the normal released version of applications. In addition, the overhead can be made quite low by just increasing the interval between samples. While the sampling approach has many advantages, the information it produces is incomplete. Low frequency events can easily fall between sampling events and never be observed by the sampling process.